<template>
  <div>
    <button @click="btnClick" v-if="isShow">切换显示隐藏</button>
    <hr />
  </div>
</template>

<script setup>
import { ref, nextTick } from "vue";
const sleep = (time) => {
  return new Promise((res) => {
    setTimeout(() => {
      res();
    }, time);
  });
};
const isShow = ref(true);
const btnClick = async () => {
  isShow.value = false;
  await sleep(1000);
  // await nextTick();
  nextTick(() => {
    isShow.value = true;
  });
};
</script>
<style scoped lang="stylus">
.btn
  padding: 20px 20px;
</style>
